package com.example.demo;

import com.example.demo.entity.Test;
import com.example.demo.repo.ITestRepo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.CommandLineRunner;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;

import java.util.Calendar;
import java.util.Date;
import java.util.List;

@SpringBootApplication
public class DemoApplication implements CommandLineRunner {

    public static void main(String[] args) {
        SpringApplication.run(DemoApplication.class, args);
    }

    @Autowired
    ITestRepo testRepo;

    @Override
    public void run(String... args) throws Exception {
        Calendar instance = Calendar.getInstance();

        instance.set(Calendar.MONTH, -3);

        List<Test> all = testRepo.findByCreateTimeBetweenAndIdIn(instance.getTime(), new Date(), new Long[]{1L, 2L, 3L});
        all.forEach(test -> System.out.println(test.getId()));
//        Test test = new Test();
//        test.setCreateTime(instance.getTime());
//        try {
//            testRepo.save(test);
//        } catch (Exception e) {
//            e.printStackTrace();
//        }
    }
}

